#!/usr/bin/perl -w
use strict;

if(!defined $ARGV[0]){
	print "Invalid args. Specify config file\n";
	exit(0);
}
my $run_counter = 0;
while($run_counter < 6){

my $config_fn = $ARGV[0];
my $config_fh;
open $config_fh,$config_fn or die("can not open at $!\n");
my @contents = <$config_fh>;
close $config_fh;

my @out;
foreach my $line(@contents){
	my $temp;
	$temp = $line;
	if($line =~ /(bwa_sam_wgsim_args=\s-R\s)(.*)(\s)(-N\s)(\d+)/){
		$temp = $1.($2+0.1).$3.$4.$5."\n";
	}
	push @out,$temp;
}

open $config_fh,">".$config_fn or die("can not open at $!\n");

foreach my $line(@out){
        print $config_fh $line;
}
close $config_fh;

system("run_pipeline.pl $ARGV[0]");
$run_counter++;
}
